{extend name='public/_home' /}

{block name='title'}栏目编辑{/block}

{block name='main'}
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li class="active">
                        <i class="fa fa-home"></i>&nbsp;栏目管理
                    </li>
                    <li>
                        栏目编辑
                    </li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->
            <!-- Page Body -->
            <div class="page-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="widget radius-bordered">
                            <div class="widget-header bordered-bottom bordered-themeprimary">
                                <span class="widget-caption">栏目添加</span>
                            </div>
                            <div class="widget-body">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label for="catename" class="col-sm-2 control-label no-padding-right">栏目名称</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="catename" value="{$cateInfo.catename}" />
                                            <p class="help-block">请输入栏目名称</p>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="catename" class="col-sm-2 control-label no-padding-right">排序</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" name="sort" value="{$cateInfo.sort}" />
                                            <p class="help-block">数字越大越往后</p>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-10">
                                            <button type="submit" class="btn btn-primary" id="cateUpdate">保存</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
{/block}

{block name="js"}
<script>
    $(function () {
        $('#cateUpdate').click(function () {
            $.ajax({
                url: "{:url('admin/cate/edit?id='.$cateInfo.id)}",
                type: "post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 2000
                        }, function () {
                            location.href = data.url
                        })
                    } else {
                        layer.open({
                            title: "操作失败",
                            icon: 5,
                            content: data.msg
                        })
                    }
                }
            })
            return false;
        });
    });
</script>
{/block}